package CS4310.csueb.story;

import CS4310.csueb.characters.Hero;
import CS4310.csueb.visual.SpriteManager;

/**
 * The class that models a Mission in the game. It is
 * comprised of the list of objectives which make up one
 * game mission.
 *
 * @author Levester Chaney
 * 
 */
public class Mission implements Objective
{
	private String name;
	private Objective objectives[];
	
	public Mission(int count)
	{
		name = "";
		objectives = new Objective[count];
	}
	
	public Mission(String s, int count)
	{
		name = s;
		objectives = new Objective[count];
	}
	
	/**
	 * Inserts the title of the mission
	 * @param s The title of the mission
	 */
	protected void addTitle(String s)
	{
		name = s;
	}
	
	/**
	 * Inserts the given objective at the next location in
	 * the list
	 * @param o The objective to insert
	 */
	protected void addObjective(Objective o)
	{
		for(int i = 0; i < objectives.length; i++)
		{
			if(objectives[i] == null)
			{
				objectives[i] = o;
				break;
			}
		}
	}
	
	/**
	 * Retrieves the list of objectives. This is to be
	 * used by the bio frame for displaying.
	 * @return the list of objectives associated with
	 * 			this mission
	 */
	public Objective[] getObjectives()
	{
		return this.objectives;
	}
	
	public String toString()
	{
		return this.name;
	}
	
	@Override
	public boolean isComplete(Hero h, SpriteManager s)
	{
		boolean done = true;
		
		for(Objective o : objectives)
			done &= o.isComplete(h, s);
		
		return done;
	}

	@Override
	public String addStory()
	{
		return "";
	}

	@Override
	public String description()
	{
		return this.name;
	}
}
